package com.example.app2024.viewmodel;

import android.app.Activity;

import androidx.lifecycle.MediatorLiveData;
import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;

public class MyViewModelWithLiveData extends ViewModel
{
      private MutableLiveData<Integer> LikedNumber;


      public MutableLiveData<Integer> getLikedNumber()
      {
            if (LikedNumber == null)
            {
                  LikedNumber = new MediatorLiveData<>();
                  LikedNumber.setValue(0);
            }
            return LikedNumber;
      }

      public void addLikedNumber(int n)
      {
            LikedNumber.setValue(LikedNumber.getValue() + n);
      }

      public void addone()
      {
            LikedNumber.setValue(LikedNumber.getValue() + 1);
      }
}
